home *** CD-ROM | disk | FTP | other *** search
- Path: mozo.cc.purdue.edu!not-for-mail
- From: hrubin@b.stat.purdue.edu (Herman Rubin)
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Subject: Re: Access carry flag from C
- Date: 6 Mar 1996 04:34:29 -0500
- Organization: Purdue University Statistics Department
- Message-ID: <4hjm75$18u8@b.stat.purdue.edu>
- References: <4h1veoINNlns@anvil.ugrad.cs.ubc.ca> <fgrieu-0403961143580001@ppp78.micronet.fr> <4hhbt8$1d3o@b.stat.purdue.edu> <Dnssxu.JGy@cwi.nl>
- NNTP-Posting-Host: b.stat.purdue.edu
-
- In article <Dnssxu.JGy@cwi.nl>, Dik T. Winter <dik@cwi.nl> wrote:
- >In article <4hhbt8$1d3o@b.stat.purdue.edu> hrubin@b.stat.purdue.edu (Herman Rubin) writes:
- > > In article <fgrieu-0403961143580001@ppp78.micronet.fr>,
- > > Franτois Grieu <fgrieu@micronet.fr> wrote:
-
- > > > if (x + yl < yl) ++yh; /* test for overflow on next line */
- > > > yl += x;
- >...
- > > Notice that in the above code, each addition must be performed twice.
-
- >Wrong. Even a mediocre compiler will optimize this away.
-
- Even if this is done, there are still two additions, as the comparison
- is normally done by an addition in hardware. Add this to the overhead
- of the test, and much time is used.
-
- > > BTW, there is a weakness in the code; ++yh can cause a carry, so
- > > another test is needed. As testing is expensive, what is needed in
- > > this case is not a test for carry, but the ability to add the carry
- > > bit to something.
-
- >But the code above also works on machines without carry bit.
-
- This still affects the result.
-
- On machines without the carry bit, an efficient mp routine would
- use a few less bits in the word, so that all these tests would
- not be needed. One is rarely interested in EXACTLY double the
- precision provided by the hardware, just as one is rarely interested
- in exactly the precision of the hardware.
- --
- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
- hrubin@stat.purdue.edu Phone: (317)494-6054 FAX: (317)494-0558
-